package cn.iocoder.yudao.module.resource.enums;

import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 积分类型枚举
 *
 * @author 芋道源码
 */
@Getter
@AllArgsConstructor
public enum PointsTypeEnum implements ArrayValuable<Integer> {

    CREATOR_REGISTER(1, "创作者入驻"),
    MATERIAL_UPLOAD(2, "素材上传"),
    MATERIAL_COLLECT(3, "素材被收藏"),
    MATERIAL_DOWNLOAD(4, "素材被下载");

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(PointsTypeEnum::getType).toArray(Integer[]::new);

    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static boolean isRegister(Integer type) {
        return ObjUtil.equal(CREATOR_REGISTER.type, type);
    }

    public static boolean isUpload(Integer type) {
        return ObjUtil.equal(MATERIAL_UPLOAD.type, type);
    }

    public static boolean isCollect(Integer type) {
        return ObjUtil.equal(MATERIAL_COLLECT.type, type);
    }

    public static boolean isDownload(Integer type) {
        return ObjUtil.equal(MATERIAL_DOWNLOAD.type, type);
    }

}
